
*Open data set "Correction Robust Data"

*Creating party variables
gen dem = 0
recode dem 0/0 = 1 if pid < 4

gen rep = 0
recode rep 0/0 = 1 if pid > 4

sum dem rep
tab pid

*Creating the variable perceptions of support for partisan violence (SPV)
sum moutthreat moutharass moutviolgoals moutviolelec
corr moutthreat moutharass moutviolgoals moutviolelec
alpha moutthreat moutharass moutviolgoals moutviolelec
egen mviol = rowmean(moutthreat moutharass moutviolgoals moutviolelec)

*Creating the varaible support for partisan violence (SPV)
sum threat harass violgoals violelec 
corr threat harass violgoals violelec 
alpha threat harass violgoals violelec 
egen viol = rowmean( threat harass violgoals violelec)

*Creating the variable perceptions of support for undemocratic practices (SUP)
sum moutban moutcourt moutfreeze moutvoting moutlaws moutviollaws moutconst 
corr moutban moutcourt moutfreeze moutvoting moutlaws moutviollaws moutconst 
alpha moutban moutcourt moutfreeze moutvoting moutlaws moutviollaws moutconst 
egen mdemnorms = rowmean(moutban moutcourt moutfreeze moutvoting moutlaws moutviollaws moutconst)

*Creating the variable support for undemocratic practices (SUP)
sum ban court freeze voting laws viollaws const
corr ban court freeze voting laws viollaws const
alpha ban court freeze voting laws viollaws const
egen demnorms = rowmean(ban court freeze voting laws viollaws const)


*Condition Ns (condition 1 = contorol, 2 = correction, 3 = correction and uncertainty, 4 = correction and competition)
tab condition

*Figure 1 means (GRAPH USES CIPLOT COMMAND)
sum mviol viol mdemnorms demnorms if condition == 1 

*Figure 1 Significance tests
ttest mviol = viol if condition == 1 
ttest mdemnorms = demnorms if condition == 1 

*Correlation between perceptions and support for control condition
pwcorr mviol viol, sig, if condition == 1
pwcorr mdemnorms demnorms, sig, if condition == 1 

regress viol mviol  if condition == 1 
regress demnorms mdemnorms if condition == 1 

*Figure 2 means and signficant tests
tab condition, sum(viol)
tab condition, sum(demnorms)
ttest viol, by(condition), if (condition == 1 | condition == 2)
ttest demnorms, by(condition), if (condition == 1 | condition == 2)

ttest viol, by(condition), if (condition == 1 | condition == 3)
ttest demnorms, by(condition), if (condition == 1 | condition == 3)

ttest viol, by(condition), if (condition == 1 | condition == 4)
ttest demnorms, by(condition), if (condition == 1 | condition == 4) 

ttest viol, by(condition), if (condition == 2 | condition == 3) 
ttest demnorms, by(condition), if (condition == 2 | condition == 3)

ttest viol, by(condition), if (condition == 2 | condition == 4) 
ttest demnorms, by(condition), if (condition == 2 | condition == 4) 


*To create Figure 2 (but note it changes the data set)
/* 
SPV
collapse (mean) meanwrite= viol (sd) sdwrite=viol (count) n=viol, by( condition )
generate hiwrite = meanwrite + invttail(n-1,0.025)*(sdwrite / sqrt(n))
generate lowrite = meanwrite - invttail(n-1,0.025)*(sdwrite / sqrt(n))
twoway (bar meanwrite condition ) (rcap hiwrite lowrite condition )

SUP
collapse (mean) meanwrite= demnorms (sd) sdwrite=viol (count) n=demnorms, by( condition )
generate hiwrite = meanwrite + invttail(n-1,0.025)*(sdwrite / sqrt(n))
generate lowrite = meanwrite - invttail(n-1,0.025)*(sdwrite / sqrt(n))
twoway (bar meanwrite condition ) (rcap hiwrite lowrite condition )

*/

**Correlation between perceptions and support for treatment conditions
pwcorr mviol viol, sig, if condition == 2 
pwcorr mdemnorms demnorms, sig, if condition == 2

pwcorr mviol viol, sig, if condition == 3
pwcorr mdemnorms demnorms, sig, if condition == 3 

pwcorr mviol viol, sig, if condition == 4
pwcorr mdemnorms demnorms, sig, if condition == 4 


*Supporting Information Results
tab age
tab gender
sum white black asian hispanic natam other
tab educ

*Results analogous to Figure 1 for treatment conditions
ttest mviol = viol if condition == 2
ttest mdemnorms = demnorms if condition == 2 
ttest mviol = viol if condition == 3 
ttest mdemnorms = demnorms if condition == 3 
ttest mviol = viol if condition == 4 
ttest mdemnorms = demnorms if condition == 4 

*Results analogous to Figure 1 and treatment conditions by party
ttest mviol = viol if condition == 1 & dem == 1
ttest mdemnorms = demnorms if condition == 1 & dem == 1
ttest mviol = viol if condition == 2 & dem == 1
ttest mdemnorms = demnorms if condition == 2 & dem == 1
ttest mviol = viol if condition == 3  & dem == 1
ttest mdemnorms = demnorms if condition == 3  & dem == 1
ttest mviol = viol if condition == 4  & dem == 1
ttest mdemnorms = demnorms if condition == 4  & dem == 1

ttest mviol = viol if condition == 1 & rep == 1
ttest mdemnorms = demnorms if condition == 1 & rep == 1
ttest mviol = viol if condition == 2 & rep == 1
ttest mdemnorms = demnorms if condition == 2 & rep == 1
ttest mviol = viol if condition == 3 & rep == 1
ttest mdemnorms = demnorms if condition == 3 & rep == 1
ttest mviol = viol if condition == 4 & rep == 1
ttest mdemnorms = demnorms if condition == 4 & rep == 1

*Results analogous to Figure 1 for all conditions and then by party across conditions
ttest mviol = viol 
ttest mdemnorms = demnorms 
ttest mviol = viol if dem == 1
ttest mviol = viol if rep == 1
ttest mdemnorms = demnorms if dem == 1
ttest mdemnorms = demnorms if rep == 1

*Mean support scores by party
tab condition, sum(viol), if dem == 1
tab condition, sum(viol), if rep == 1

tab condition, sum(demnorms), if dem == 1
tab condition, sum(demnorms), if rep == 1


ttest viol, by(condition), if (condition == 1 | condition == 2) & dem == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 2) & dem == 1

ttest viol, by(condition), if (condition == 1 | condition == 3) & dem == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 3) & dem == 1

ttest viol, by(condition), if (condition == 1 | condition == 4) & dem == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 4) & dem == 1

ttest viol, by(condition), if (condition == 2 | condition == 3) & dem == 1
ttest demnorms, by(condition), if (condition == 2 | condition == 3) & dem == 1

ttest viol, by(condition), if (condition == 2 | condition == 4) & dem == 1
ttest demnorms, by(condition), if (condition == 2 | condition == 4) & dem == 1



ttest viol, by(condition), if (condition == 1 | condition == 2) & rep == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 2) & rep == 1

ttest viol, by(condition), if (condition == 1 | condition == 3) & rep == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 3) & rep == 1

ttest viol, by(condition), if (condition == 1 | condition == 4) & rep == 1
ttest demnorms, by(condition), if (condition == 1 | condition == 4) & rep == 1

ttest viol, by(condition), if (condition == 2 | condition == 3) & rep == 1
ttest demnorms, by(condition), if (condition == 2 | condition == 3) & rep == 1

ttest viol, by(condition), if (condition == 2 | condition == 4) & rep == 1
ttest demnorms, by(condition), if (condition == 2 | condition == 4) & rep == 1


********************************************************************************************************
*The survey included various other variables not analyzed in the paper. Below provides code for creating variables

*creating  political knowledge
gen polknow = (cknowveto + cknowhouse + cknowcourt + cknowvp + cknowconserv)/5


*creating self monitoring
corr entertain actor centerattention
alpha entertain actor centerattention
egen notselfmonitor = rowmean(entertain actor centerattention)
gen selfmon = 100-notselfmonitor

*creating agreesiveness 
corr blows hitperson threatenedpepole 
alpha blows hitperson threatenedpepole 
egen aggres = rowmean(blows hitperson threatenedpepole )
 
*creating anti-establishment orientation
corr fewrunthings votersnotknow smallpower secretplots ordinarypeople studynotknow govaccnot poligoodevil 
alpha fewrunthings votersnotknow smallpower secretplots ordinarypeople studynotknow govaccnot poligoodevil 
egen antiestab = rowmean(fewrunthings votersnotknow smallpower secretplots ordinarypeople studynotknow govaccnot poligoodevil)

*creatng authoritarianism
gen flipdefyautho = 100 - defyautho
gen flippresex = 100-presex
gen flipnottoughtlaws = 100-nottoughtlaws
corr flipdefyautho discipline godfollow flippresex flipnottoughtlaws crackdown 
alpha flipdefyautho discipline godfollow flippresex flipnottoughtlaws crackdown 
egen authorit = rowmean(flipdefyautho discipline godfollow flippresex flipnottoughtlaws crackdown)

*creating ethnic antoganism
gen flipimmigcontri = 100-immigcontri
corr welfarebetteroff stranger discwhite flipimmigcontri
alpha welfarebetteroff stranger discwhite flipimmigcontri
egen ethnicant = rowmean(welfarebetteroff stranger discwhite flipimmigcontri)

*creating partisanship as a social identity
corr psidimp psiddescribe
alpha psidimp psiddescribe
egen PSID = rowmean(psidimp psiddescribe)

sum selfmon aggres antiestab authorit ethnicant PSID

sum outtherm intherm rateoutevol 

*creating policy views (extremism)
corr servspend defense govblack abortion medinsur 
alpha servspend defense govblack abortion medinsur 
egen policyextrem = rowmean(servspend defense govblack abortion medinsur)

*creating condition dummies and interations with perceptions of other party
gen correction = condition
recode correction 1/1 = 0 2/2 =1 3/4 = 0
tab correction
gen corrmviol =  correction*mviol
gen corrmdemnorms = correction*mdemnorms

gen polls = condition
recode polls 1/2 = 0 3/3 =1 4/4 = 0
tab polls
gen pollsmviol =  polls*mviol
gen pollsmdemnorms = polls*mdemnorms

gen compete = condition
recode compete 1/3 = 0 4/4 = 1
tab compete
gen competemviol =  compete*mviol
gen competemdemnorms = compete*mdemnorms


*Regressions of SPV and SUP on conditions and interactions to see which conditions lesson the impact of the perceptions

**NOTE that one finding of note here (not explained in the paper is that Democrats largely match the overall results, while Republicans do not display a statistically significant interaction between the correction condition and misperceptions. This is the case even though the correction significantly reduces the overall scores for Republicans for both outcomes. This suggests other possible mediational processes for Republicans (perhaps involving norms).

regress viol mviol correction polls compete  corrmviol pollsmviol competemviol
regress demnorms mdemnorms correction polls compete corrmdemnorms pollsmdemnorms competemdemnorms

*Regressions with all controls
regress viol mviol correction polls compete  corrmviol pollsmviol competemviol  pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem rateoutevol 

regress demnorms mdemnorms correction polls compete corrmdemnorms pollsmdemnorms competemdemnorms pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem rateoutevol 

regress viol mviol correction polls compete  corrmviol pollsmviol competemviol  pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem  rateoutevol if dem == 1

regress viol mviol correction polls compete  corrmviol pollsmviol competemviol  pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem  rateoutevol if rep == 1

regress demnorms mdemnorms correction polls compete corrmdemnorms pollsmdemnorms competemdemnorms pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem rateoutevol if dem == 1

regress demnorms mdemnorms correction polls compete corrmdemnorms pollsmdemnorms competemdemnorms pid interest educ income black hispanic asian female age outtherm polknow selfmon aggres authorit ethnicant antiestab policyextrem rateoutevol if rep == 1






